package kuonta.domain;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name="tb_itens_recibo")
public class ItemRecibo {

	@Id
	@Column(name="id_item")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	
	@Column(name="valor")
	private BigDecimal valor;
		
	@Column(name="data_item")
	private Date data;
	
	@OneToOne
	@JoinColumn(name="id_tipo_item")
	private TipoItemRecibo tipo;
		
	@ManyToOne
	@JoinColumn(name="id_recibo")
	private Recibo recibo;
			
	public ItemRecibo() {
		// TODO Auto-generated constructor stub
	}
		
	public TipoItemRecibo getTipo() {
		return tipo;
	}

	public void setTipo(TipoItemRecibo tipo) {
		this.tipo = tipo;
	}

	public Recibo getRecibo() {
		return recibo;
	}

	public void setRecibo(Recibo recibo) {
		this.recibo = recibo;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public BigDecimal getValor() {
		return valor;
	}

	public void setValor(BigDecimal valor) {
		this.valor = valor;
	}
	
	public Date getData() {
		return data;
	}

	public void setData(Date data) {
		this.data = data;
	}	

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ItemRecibo other = (ItemRecibo) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
}
